package com.bruce.pullrefresh;

import android.support.v7.widget.RecyclerView;
import android.view.View;

/**
 * Created by Administrator on 2015/8/27.
 */
public abstract class BaseViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener,View.OnLongClickListener {

    public BaseViewHolder(View itemView,MyItemClickListener listener,MyItemLongClickListener longClickListener) {
        super(itemView);
        mListener=listener;
        this.longClickListener=longClickListener;
        itemView.setOnClickListener(this);
        itemView.setOnClickListener(this);


    }

    private MyItemClickListener mListener;

    private MyItemLongClickListener longClickListener;

    @Override
    public boolean onLongClick(View v) {
        if(this.longClickListener!=null){
            longClickListener.onItemLongClick(v,getPosition());
        }
        return true;
    }

    @Override
    public void onClick(View v) {
        if(this.mListener!=null){
            mListener.onItemClick(v,getPosition());
        }
    }
}
